/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package mx.itschapala.com.dsw2.Dao;

import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.Query;
import mx.itschapala.com.dsw2.modelo.InventarioAlmacen;

/**
 *
 * @author z
 */
@Stateless
public class InventarioAlmacenDao extends AbstractDao<InventarioAlmacen> implements InventarioAlmacenDaoLocal {
    @PersistenceContext(unitName = "Inventario1-ejbPU")
    private EntityManager em;

    @Override
    protected EntityManager getEntityManager() {
        return em;
    }

    public InventarioAlmacenDao() {
        super(InventarioAlmacen.class);
    }

    @Override
    public boolean findDuplicity(InventarioAlmacen inventory) {
        //seleccionar  consulta 
        Query q = em.createNamedQuery("InventarioAlmacen.findDuplicity");
        //poner parametro
        q.setParameter("nombre", inventory.getNombre());
        q.setParameter("apellidoPaterno", inventory.getCantidad());
        q.setParameter("apellidoMaterno",inventory.getFechaIngreso());
        q.setParameter("apellidoMaterno",inventory.getHora());
        q.setParameter("apellidoMaterno",inventory.getIdInventario());
        q.setParameter("apellidoMaterno",inventory.getReportesalidaProducto());
        q.setParameter("apellidoMaterno",inventory.getUsurio());
        //ejecutar  la  consulta
         return !q.getResultList().isEmpty();
    }
    
}
